package com.vueblog.webapi.test;

import sun.applet.Main;

/**
 * @author lsj
 * @create 2021-06-16 16:37
 */
public class Conductor extends Thread{

    static int ticket = 50;

    @Override
    public void run(){
        while (true){
            show();
        }
    }

    public static synchronized void show() {

        if (ticket > 0) {
            try {
                Thread.sleep(30);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

            System.out.println(Thread.currentThread().getName() + "卖票，当前票号为：" + ticket);
            ticket--;
        }

    }
}

class SellTest{
    public static void main(String[] args) {
        Conductor conductor1 = new Conductor();
        Conductor conductor2 = new Conductor();
        Conductor conductor3 = new Conductor();

        conductor1.setName("窗口1");
        conductor2.setName("窗口2");
        conductor3.setName("窗口3");

        conductor1.start();
        conductor2.start();
        conductor3.start();
    }
}